<?php
namespace app\shop\library;

use cubox\Controller;
use cubox\provider\response\Ajax;
use app\shop\library\Member;
use cubox\Cubox;

class ApiController extends Controller{
    public function __construct()
    {   
        Cubox::response(Ajax::class);
        parent::__construct();
        Member::headerToken();

        try{
            $request = file_get_contents('php://input');
            if ($request){
                $this->posts = json_decode($request,true);
            }
        }catch(\Exception $e){
            throw new \Exception('参数错误');
        }
    }
    protected function getCacheName($name,$suffix=''){
        return self::cacheName($name,$suffix);
    }

    public static function cacheName($name,$suffix=''){
        return  'shopapi_'.$name.($suffix!=''?(':'.$suffix):'');
    }
}